package org.lex.app.sessions;

import java.awt.Component;
import java.awt.Frame;

public class FrameSession extends WindowSession {
	private static final String FRAME_STATE = "state";
	private static final String FRAME_EXT_STATE = "extState";

	@Override
	public FrameSession getComponentProperties(Component c) {
		this.clear();
		super.getComponentProperties(c);
		Frame f = (Frame) c;
		this.putInt(FRAME_STATE, f.getState());
		this.putInt(FRAME_EXT_STATE, f.getExtendedState());
		return this;
	}

	@Override
	public void restoreComponent(Component c) {
		super.restoreComponent(c);
		int state = this.getInt(FRAME_STATE, -1);
		Frame f = (Frame) c;
		if (-1 != state)
			f.setState(state);
		int extState = this.getInt(FRAME_EXT_STATE, -1);
		if (-1 != extState)
			f.setExtendedState(extState);
	}
}
